package com.youxin.cpcenter.service.impl;

import com.youxin.busfoundation.bean.leads.RequestPoolBean;
import com.youxin.cpcenter.bean.CluePoolCompanyMemberBean;
import com.youxin.cpcenter.bean.CluePoolCompanyTotalBean;
import com.youxin.cpcenter.bean.RequestPoolCompanyTotalBean;
import com.youxin.cpcenter.dao.TbEntCluePoolCompanyMapper;
import com.youxin.cpcenter.model.TbEntCluePoolCompany;
import com.youxin.cpcenter.service.CluePoolCompanyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @desc 公司线索池
 * @author Kris.wang
 * @date 2017-12-05
 */
@Service("CluePoolCompanyService")
public class CluePoolCompanyServiceImpl implements CluePoolCompanyService {

    @Autowired
    private TbEntCluePoolCompanyMapper tbEntCluePoolCompanyMapper;

    /**
     * @desc 根据用户ID和企业UID判断是否已收藏
     * @param bean
     * @return
     */
    @Override
    public int verify(RequestPoolBean bean) {
        return tbEntCluePoolCompanyMapper.selectByFollowIdAndComUid(bean);
    }

    /**
     * @desc 根据企业UID和收藏的企业UID查询最新一条收藏记录
     * @param bean
     * @return
     */
    @Override
    public TbEntCluePoolCompany selectLatestRecord(RequestPoolBean bean) {
        return tbEntCluePoolCompanyMapper.selectLastRecordByComUid(bean.getCompanyUid());
    }

    /**
     * @desc 根据企业UID获取跟进人
     * @param companyUid
     * @return
     */
    @Override
    public List<CluePoolCompanyMemberBean> selectMemberByComUid(String companyUid) {
        return tbEntCluePoolCompanyMapper.selectMemberByComUid(companyUid);
    }

    /**
     * @desc 统计企业中不同状态的企业线索池
     * @param bean
     * @return
     */
    @Override
    public List<CluePoolCompanyTotalBean> total(RequestPoolCompanyTotalBean bean) {
        return tbEntCluePoolCompanyMapper.total(bean);
    }

}
